using HeadspringExample.Core.Domain.Model;
using HeadspringExample.UI;
using HeadspringExample.UI.Helpers;
using HeadspringExample.UI.Models;
using NUnit.Framework;

namespace HeadspringExample.UITests
{
    [TestFixture]
    public class ConferencePageTester : WebTestBase
    {
        [SetUp]
        public override void SetUp()
        {
            new DummyDataLoader(SessionSource).Load();
            base.SetUp();
        }

        [Test]
        public void Should_edit_the_event_name_correctly()
        {
            var conference = new Conference("Austin Code Camp");
            SaveEntities(conference);
            //needed data is now in application

            NavigateLink(SiteNav.Conferences);

            NavigateLink(EditLink("Austin Code Camp"));

            ForForm<ConferenceEditModel>()
                .WithTextBox(x => x.Name, "Desert Code Camp")
                .Save();

            CurrentPageShouldBe(SiteNav.Page.Conference.Index);

            VerifyLinkExists(ShowLink("Desert Code Camp"));
        }

        private string EditLink(string value)
        {
            return string.Format("Edit {0}", value);
        }

        private string ShowLink(string value)
        {
            return string.Format("Show {0}", value);
        }

        [Test]
        public void Lots_of_test()
        {
            for (int i = 0; i < 50; i++)
            {
                Should_edit_the_event_name_correctly();
            }
        }

    }
}